package zcw.com.lib_leet_code;

/**
 * Created by 朱城委 on 2021/7/19.<br><br>
 *
 * 提莫攻击
 */
public class Topic495 {

    public static void main(String[] args) {
        Topic495 instance = new Topic495();

        int[] array = new int[] {1, 4};
        System.out.println(instance.findPoisonedDuration(array, 2));

        array = new int[] {1, 2};
        System.out.println(instance.findPoisonedDuration(array, 2));
    }

    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int counter = 0;

        for(int i = 1; i < timeSeries.length; i++) {
            counter += Math.min(timeSeries[i] - timeSeries[i - 1], duration);
        }

        counter += duration;
        return counter;
    }
}
